import java.io.File;
import java.util.List;
import netcracker.Finder;
/**
 * 
 * @author den
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//System.out.println(System.getProperty("user.dir"));
		if (args!=null && args.length >= 4){
			if (args[0].contains("find") && (args[2].contains("-e") || args[2].contains("-n"))){
				Finder find = new Finder();
				List res = null;
				try {
					switch (args[2]){
					case "-e":
						res = find.findAll(args[1], ".+" + args[3], 0);
						break;
					case "-n":
						res = find.findAll(args[1], args[3], 1);
						break;
					}
				}
				catch (Exception ex){
					System.out.println(ex.getMessage());
				}
				if (res!=null){
					System.out.println("Found " + res.size() + " files:");
					for (int i=0;i<res.size();i++){
						File file=(File)res.get(i);
						System.out.println((i + 1) + ". " + file.getPath());
					}
				}
				else System.out.println("Found 0 files");
			}
			else {
				System.out.println("Bad args");
			}
		}
		else{
			System.out.println("No args");
		}
	}

}
